﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace ThreadDemo1
{
    class Kids
    {
        public void BoyThread()
        {

            for (int i = 0; i < 10; i++)
            {
                lock (this)
                {
                    Console.WriteLine("Boy");
                    Thread.Sleep(100);
                }
            }
        }
        public void GirlThread()
        {

            for (int i = 0; i < 10; i++)
            {
                lock (this)
                {
                    Console.WriteLine("Girl");
                    Thread.Sleep(100);
                }
            }
        }
    }
}
